﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using Com.Stockstar.Quote.Common.Quote;
using System.Configuration;
using log4net;
using System.Text.RegularExpressions;
namespace Web
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {

            //log4net日志配置
            log4net.Config.XmlConfigurator.Configure();

            #region 从SG接口获取数据

            //获取行情快照
            SnapSingleton.Start();

            //获取行业指数
            IndustryIndexSingleton.Start();

            //行业成分股
            IndustryStockSingleton.CacheData(null);

            #endregion
        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {
            //HttpApplication app = (HttpApplication)sender;
            //string requestedPath = app.Request.Path;
            //if (!requestedPath.ToLower().EndsWith("css") && !requestedPath.ToLower().EndsWith("js") && !requestedPath.ToLower().EndsWith("jpg") && !requestedPath.ToLower().EndsWith("gif") && !requestedPath.ToLower().EndsWith("png") && !requestedPath.ToLower().EndsWith("ashx"))
            //{
            //    string code = "BSGS";
            //    if (requestedPath.IndexOf(".aspx") > 0)
            //    {
            //        code = requestedPath.Substring(requestedPath.LastIndexOf("/") + 1);
            //        code = code.Substring(0, code.IndexOf("."));
            //    }
            //    app.Context.RewritePath("Default.aspx?code=" + code);
            //}
        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}